home *** CD-ROM | disk | FTP | other *** search
Text File | 1997-07-15 | 9.7 KB | 244 lines | [TEXT/CWIE] |
- /*******************************************************************************\
- | |
- | HMarqueeCaption ©1997 John C. Daub. All rights reserved. |
- | |
- | John C. Daub <mailto:hsoi@eden.com> |
- | <http://www.eden.com/~hsoi/> <http://www.eden.com/~hsoi/prog.html> |
- | |
- \*******************************************************************************/
-
-
- DESCRIPTION
- ```````````
-
- A Metrowerks PowerPlant™ inherited class that displays a horizontally scrolling
- (from right to left) "marquee" of text, similar in appearance to the scrolling
- JavaScript marquee that you often see across the bottom of web browser windows.
-
- Features:
-
- - Utilizes offscreen GWorlds for smooth scrolling of text.
-
- - Uses text Handles for an amount of text limited only by available memory.
-
- - Utilizes modifier keys to modify scrolling behavior (increase scrolling
- speed, scroll left to right, pause scrolling).
-
- Can be used in About boxes for scrolling credits, in JavaScript implementations
- for the scrolling caption, in applications that need ticker-tape-style
- animations, or anywhere a marquee-style sign and animation is desired.
-
- The HMarqueeCaption distribution contains the HMarqueeCaption class, a CTYP
- resource for easier editing in Metrowerks Constructor™, and a demonstration
- application to show just how easy it is to use HMarqueeCaption (made with
- CodeWarrior Professional 1).
-
-
- USAGE
- `````
-
- Implementing an HMarqueeCaption in your PowerPlant-based project is very
- simple.
-
- Place the "HMarqueeCaption.CTYP" file in the "Custom Types" folder within
- the "Metrowerks PowerPlant" folder (this folder is only available in CW Pro1
- and greater. If you are working with a CodeWarrior prior to Pro1, just
- place the file in the same folder as the Constructor™ application).
-
- Launch Constructor™ and edit as usual. HMarqueeCaption should be available
- in the Catalog window for easy drag and drop editing.
-
- TEXT ID - the ResIDT of the 'TEXT' resource containing the text for
- the marquee.
-
- Text Traits ID - the ResIDT of the 'Txtr' resource for the text
-
- Delay - the amount of time (in ticks) to wait before scrolling.
- This helps to prevent the text from scrolling too fast
- (e.g. on a very high-end PowerMac).
-
- Scroll Amount - the amount (in pixels) to scroll each time through the loop
-
- Reset on Resize - when the pane (or it's superView) is resized, reset the
- caption to the beginning, or just continue from where you
- were.
-
- As general recommendations, I prefer to set Delay to 1, Scroll Amount to 1,
- and the frame bindings (if relevant) to bind to left and right. Those are my
- only recommendations... everything else is up to you.
-
- As you enter your 'TEXT', you do not need to worry about the 'styl' resource
- as this information is discarded -- a 'Txtr' is used instead. Additionally,
- any carriage returns and/or line feeds are stripped from the text before it
- is displayed (they just don't show up very well on screen) and replaced with
- spaces. Keep this in mind when "laying out" your 'TEXT' resource.
-
- Then be sure to add the HMarqueeCaption.cp to your project, register the
- class (use the RegisterClass_() macro), and off you go!
-
- During runtime, the speed of the scrolling is not only affected by the
- settings you've given it, but also some factors within and outside of
- your control.
-
- First, HMarqueeCaption is an LPeriodical repeater so the behavior is dependant
- upon the event loop. If some other application is hogging the processor,
- scrolling my be slowed greatly. The joys of cooperative multitasking.
-
- Second, the use of GWorlds, the size of the caption, etc. can affect the
- speed of the drawing. So do try to test (if possible) on lower-end machines
- to ensure performance is still adequate for your needs.
-
- Third, the modifier keys can affect the scrolling:
-
- command key - Ignores the delay amount and draws as often as SpendTime is called.
- Can improve scrolling time, especially on faster computers. Also
- gives the best scrolling in terms of cosmetics
-
- option key - Scroll one more pixel than usual. Again speeds scrolling but can
- make scrolling a bit choppy. Option and Command together REALLY
- speed things up.
-
- shift key - Scroll backwards (right to left).
-
- control key - Stop scrolling (pause)
-
- And all the keys can be used in combination: command-opt-shift will scroll very
- quickly from right to left.
-
-
- CREDITS
- ```````
-
- Thanx to Michele and Wade (my wife and my son) for letting me spend too much
- time on the computer to write things like this. :-)
-
-
- DISCLAIMER
- ``````````
-
- This is NOT a product of Metrowerks Corporation. Please do NOT contact Metrowerks
- for help/support of this class/code. If you need support, please use the contact
- information given below.
-
-
- LICENSING AND USAGE AGREEMENT
- `````````````````````````````
-
- John C. Daub (author) grants you, and you accept, a nonexclusive, nontransferable
- license to distribute this code for you within your programs and projects. You may
- distribute this code in object code form only and only on magnetic diskettes,
- CD-ROM, or other media with your programs into which this code has been
- incorporated (if you need to distribute your program by some other medium, please
- contact the author). You agree that this license gives you no title nor rights
- of ownership in, of, and/or to this code, and acknowledge that this code
- is property of John C. Daub. This code is NOT in the public domain.
-
- Permission is granted to the following organizations to distribute this
- code on their CD-ROM collections:
-
- Pacific HiTech, Inc - Info-Mac CD-ROM
- Celestin Company - Apprentice CD
- Meterowerks Corporation - CodeWarrior
-
- If you and/or your organization wishes to distribute this code and are
- not explicitly listed above, please contact John C. Daub.
-
- You may modify the source code, compile it, and incorporate the resulting object
- code into your programs. If you modify the code, you cannot redistribute the
- modified code under the same class/code name. Furthermore, to prevent any
- problems and/or infringements, please contact the author prior to redistribution
- of any modified code.
-
- John C. Daub licenses this code to you on an "AS IS" basis. John C. Daub makes
- no warranties, neither expressed nor implied, regarding this code, its
- merchantability, nor its fitness for any purpose. John C. Daub agrees to make a
- reasonable effort to provide written or verbal corrections for any problems
- that might be found in this code.
-
- Use of this code must be credited in an appropriate manner and location (such
- as printed or online documentation and/or About boxes) with the following
- credit line:
-
- HMarqueeCaption ©1997 John C. Daub. All rights reserved.
-
- If this license is too restrictive with the current law in your state or country,
- you should not use this code at all. Furthermore, if you personally find this
- agreement too restrictive or not to your satisfaction, you should not use this
- code at all.
-
-
- FUTURE
- ``````
-
- - It might be nice to optionally have the "entry" and "exit" of the caption
- fade in and out, similar to how the scrolling credits work in the CW IDE's
- About box.
-
- - A way to try to get around the event-loop dependacy on the scrolling speed.
- A lot of this is just something you have to live with due to the cooperative
- multitasking nature of the MacOS... but there could be things that could
- be done to try to get around it. Of course, would it be worth it? Perhaps
- investigate threads?
-
- - See if it might be possible that when the text wraps from beginning to end
- that there isn't such a large gap... i.e. try to have the ends "touch"
- each other (or be seperated by a set amount of space).
-
- - Multistyle?
-
- - Allow text to either scroll right to left or left to right, whatever the
- programmer wants.
-
-
- CONTACT INFORMATION
- ```````````````````
-
- Even though you don't need to send me email or register or anything to
- use the code, it would still be nice to drop me a line and let me know
- what you think. If you find any bugs or add any cool features, send them
- to me so I can add it to the official distribution. Furthermore, if I
- have your contact information, I can notify you when new versions are
- released -- can be very handy if say there is a fatal crashing bug
- in the code or some such. So, it's probably in your own best interest
- to drop me a line :-)
-
- Also, be sure to visit my web site
-
- <http://www.eden.com/~hsoi/prog.html>
-
- and "register". I won't know if you're "registered" or not, but it's a nice
- way that you can be notified of product updates (e.g. I make a new
- version, post it on that page, if you're registered, you'll be emailed
- automatically that the page changed).
-
- John C. Daub
- <mailto:hsoi@eden.com>
- <http://www.eden.com/~hsoi/prog.html>
-
-
- CHANGE HISTORY
- ``````````````
-
- Date Vers Who Notes
- ----------------------------------------------------------------------------
- 26 Jun 97 1.0 JCD - Initial release.
-
- 13 Jul 97 1.1 JCD - All ctor's use initialization lists instead of
- assignment (where possible).
- - All member data is now private (was protected). Appropriate
- accessor functions have been created (as public or
- protected, depending on context). Helps to further abstract
- the user away from the data (good C++ style).
- - Added include for PowerPlant_PCH to be consistant with
- PowerPlant sources.
- - Inline functions no longer defined within class declaration.
- Definitions moved outside of the class, but still in the header
- file. (Only affected SetTextTraitsID). #pragma mark's
- added to source file to ease navigation and user indexing.
- - All member data is now initialized properly to some
- default value (prior, some data was never properly
- initialized).
- - GetTextID now inline (in accordance with the above
- changes)
- - DisposeGWorld renamed to DestroyGWorld so as to prevent
- any conflicts with the Toolbox's DisposeGWorld.